import processing.serial.*;

Serial port;
OLED uOLED;

void setup() {
  size(200, 200);
  println("Available serial ports:");
  println(Serial.list());

  // open the first serial port
  port = new Serial(this, Serial.list()[0], 9600);
  
  // instantiate an OLED object
  uOLED = new OLED(port);
  
  // erace the background with a grey color
  uOLED.setBackgroundColor(0.5, 0.5, 0.5);
}

void draw() {
  background(255);
}

// click on the display window to draw something
void mousePressed() {
  // red, green, blue
  uOLED.setBackgroundColor(random(0, 1), random(0, 1), random(0, 1));

  // 0:solid, 1:wire frame
  uOLED.setPenSize(0);
  
  // x, y, radius, red, green, blue
  uOLED.drawCircle(50, 50, 30, 1, 0, 0);

  // x1, y1, x2, y2, red, green, blue
  uOLED.drawLine(0, 0, 100, 50, 0, 1, 1);
  
  // x1, y1, x2, y2, red, green, blue
  uOLED.drawRectangle(10, 10, 20, 20, 1, 1, 0);
  
  // x, y, type, red, green, blue, text
  uOLED.drawText(10, 10, uOLED.LARGE_SIZE_FONT, 0, 0, 0, "Hello uOLED!");
}
